
#include "syscall.h"

int main(int argc, char** argv)
{
   int ret = 0;
   char* filename = "hello.txt";
   int fd = creat( filename );
   if( fd != -1 ) {
      printf( "FileDescriptor for %s is %d\n", filename, fd );
   } else {
      printf( "error: could not create file: %s\n", filename );
      ret = -1;
   }
   int fd2 = 0;
   if( ret == 0 ) {
      fd2 = open( filename );
      if( fd2 != -1 ) {
         printf( "FileDescriptor for %s is %d\n", filename, fd2 );
      } else {
         printf( "error: could not open file: %s\n", filename );
         ret = -1;
      }
   }

   //open should have the same fd as creat
   if( fd != fd2 ) {
      printf( "Open and Creat returned different fd's\n" );
      printf( "creat: %d\n", fd );
      printf( "open:  %d\n", fd2 );
      ret = -2;
   } else {
      printf( "Open and Creat returned the same fd's: %d\n", fd );
   }

   return ret;
}
